<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <link rel="stylesheet" href="/static/css/index.css" media="all">
    <style>
        .imgs{display: none;}
        input[type="file"]{
            width: 50px;
            height:50px;
            border-radius: 100%;
            opacity:0;
            cursor:pointer;
            border: 1px solid red;
            position: absolute;
        }
    </style>
    <script src="/static/js/jquery.js"></script>

</head>
<body>

<div class="x-body">
    <blockquote class="layui-elem-quote">
        <input type="hidden" name="id" value="8">
        <div >
            <img src="/static/images/tp.jpg" class="layui-circle" style="width:50px;height:50px;float:left" id="pimages" name="pimages"   alt="个人头像" >
            <input id="avatar"   name="image" required="" type="hidden" value="/static/images/tx.jpg" >
            <dl style="margin-left:80px; color:#019688">
                <dt><span >[[${session.admin.adminName}]]</span> <span ></span></dt>
                <dd style="margin-left:0">这家伙很懒，什么也没有留下</dd>
            </dl>
        </div>
    </blockquote>

    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form" id="addForm">
                <div class="layui-form-item">
                    <label for="adminName" class="layui-form-label">
                        <span class="x-red">*</span>登录名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="adminName" name="adminName" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${session.admin.adminName}" readonly>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>将会成为您唯一的登入名
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="adminMail" class="layui-form-label">
                        <span class="x-red">*</span>邮箱
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="adminMail" name="adminMail" required="" lay-verify="email"
                               autocomplete="off" class="layui-input" th:value="${session.admin.adminMail}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="adminPassword" class="layui-form-label">
                        <span class="x-red">*</span>密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="adminPassword" name="adminPassword" required="" lay-verify="pass"
                               autocomplete="off" class="layui-input" th:value="${session.admin.adminPassword}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    密保问题
                </div>
                <div class="layui-form-item">
                    <label for="adminQuestion1" class="layui-form-label">
                        <span class="x-red">*</span>喜欢的明星
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="adminQuestion1" name="adminQuestion1" required=""
                               autocomplete="off" class="layui-input" th:value="${session.admin.adminQuestion1}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="adminQuestion2" class="layui-form-label">
                        <span class="x-red">*</span>喜欢的电影
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="adminQuestion2" name="adminQuestion2" required=""
                               autocomplete="off" class="layui-input" th:value="${session.admin.adminQuestion2}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="adminQuestion3" class="layui-form-label">
                        <span class="x-red">*</span>喜欢的菜
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="adminQuestion3" name="adminQuestion3" required=""
                               autocomplete="off" class="layui-input" th:value="${session.admin.adminQuestion3}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button  class="layui-btn" onclick="updateAdmin()">
                        保存
                    </button>
                </div>
                <input type="hidden" id="adminId" name="adminId"
                       autocomplete="off" class="layui-input" th:value="${session.admin.adminId}">
            </form>
        </div>
    </div>
</div>
</body>

<script>
function updateAdmin() {
var res;
var adminId = $("#adminId").val();
var adminName = $("#adminName").val();
var adminMail = $("#adminMail").val();
var adminPassword = $("#adminPassword").val();
var L_password = $("#L_repass").val();
var adminQuestion1 = $("#adminQuestion1").val();
var adminQuestion2 = $("#adminQuestion2").val();
var adminQuestion3 = $("#adminQuestion3").val();
if (adminPassword!=L_password){
    alert("两次密码不一样");
}else {
    $.ajax({
        url:'updateAdminInfo',
        method:'post',
        async:false,
        data:{'adminId':adminId,'adminName':adminName,'adminMail':adminMail,'adminPassword':adminPassword ,'adminQuestion1':adminQuestion1, 'adminQuestion2':adminQuestion2, 'adminQuestion3':adminQuestion3},
        success:function (data) {
            res=data;
        }
    })
    if (res=="1"){
        location.reload();
    }else {
        window.location.href = "toErrorPage"
    }
}
}
</script>
</html>